﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Xww.LCV {
   /*
    public static class LCVPValueRegex {
        public static void CalculatePValueByRegex(this LCSCollection LCSs, IEnumerable<string> positiveSet, IEnumerable<string> negativeSet) {
            var collection = LCSs.Select(o => new LCVWrapper(o)).ToList();

            //分别统计LCV在正负集中出现的总次数
            int possetcount=0, negsetcount=0;
            foreach (string sequence in positiveSet) {
                ++possetcount;
                collection.ForEach(o => o.CountInPosSet += (o.Regex.IsMatch(sequence)?1:0) );
            }
            foreach (string sequence in negativeSet) {
                ++negsetcount;
                collection.ForEach(o => o.CountInNegSet += (o.Regex.IsMatch(sequence) ? 1 : 0));
            }
            //统计次数 END
            foreach (var item in collection) {
                double P_neg = (double) item.CountInNegSet / negsetcount;
                if( P_neg >1) P_neg =1;
                item.LCS.PValue = alglib.binomialdistr.binomialcdistribution(item.CountInPosSet - 1, possetcount, P_neg);
            }
        }


        class LCVWrapper  {
            public int CountInPosSet { get; set; }
            public int CountInNegSet { get; set; }
            public LCS LCS{get;private set;}
            public Regex Regex { get; set; }
            public LCVWrapper(LCS origin){
                LCS = origin;
                Regex = origin.REGEX;
                CountInPosSet = CountInNegSet = 0;
            }
        }
        
    }
*/
}
